<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FastAPI 人脸识别系统</title>
    <!-- 引入 Bootstrap 5 CSS -->
    <link href="{{ url_for('static', path='css/bootstrap.min.css') }}" rel="stylesheet">
    <style>
        body { background-color: #f8f9fa; }
        .card-img-top { width: 100%; height: 18vw; object-fit: cover; }
        @media (max-width: 768px) { .card-img-top { height: 50vw; } }
        #recognition-result-card { display: none; }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-dark bg-dark">
        <div class="container-fluid">
            <a class="navbar-brand" href="#">
                FastAPI + 深度学习：人脸识别系统
            </a>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="row">
            <!-- 左侧：在线识别区域 -->
            <div class="col-md-5">
                <h3>1. 在线识别</h3>
                <div class="card">
                    <div class="card-body">
                        <form id="recognition-form">
                            <div class="mb-3">
                                <label for="recognition-image" class="form-label">上传待识别人脸图片</label>
                                <input class="form-control" type="file" id="recognition-image" name="photo" accept="image/*" required>
                            </div>
                            <img id="image-preview" src="" class="img-fluid rounded mb-3" alt="图片预览" style="max-height: 300px; display: none;">
                            <button type="submit" class="btn btn-primary w-100">开始识别</button>
                        </form>
                    </div>
                </div>
                <!-- 识别结果显示卡片 -->
                <div id="recognition-result-card" class="card mt-3">
                    <div class="card-header">识别结果</div>
                    <div class="card-body">
                        <h5 class="card-title">最相似人物: <span id="result-name"></span></h5>
                        <p class="card-text">相似度: <span id="result-similarity" class="fw-bold"></span></p>
                    </div>
                </div>
                 <div id="alert-container-rec" class="mt-3"></div>
            </div>

            <!-- 右侧：人物库管理区域 -->
            <div class="col-md-7">
                <h3>2. 人物库管理</h3>
                <!-- 添加人物表单 -->
                <div class="card mb-4">
                    <div class="card-body">
                        <h5 class="card-title">添加新人物</h5>
                        <form id="add-person-form">
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label for="person-name" class="form-label">姓名</label>
                                    <input type="text" class="form-control" id="person-name" name="chinese_name" required>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label for="person-photo" class="form-label">照片 (请确保包含清晰人脸)</label>
                                    <input type="file" class="form-control" id="person-photo" name="photo" accept="image/*" required>
                                </div>
                            </div>
                            <button type="submit" class="btn btn-success w-100">确认添加</button>
                        </form>
                         <div id="alert-container-add" class="mt-3"></div>
                    </div>
                </div>
                <!-- 人物列表 -->
                <h5>已录入人物</h5>
                <div id="person-list" class="row row-cols-2 row-cols-md-3 g-4">
                    <!-- 人物卡片将通过JS动态插入这里 -->
                </div>
            </div>
        </div>
    </div>

    <!-- 引入我们自己的JS文件 -->
    <script src="{{ url_for('static', path='js/app.js') }}"></script>
</body>
</html>